////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2002.
// -------------------------------------------------------------------------
//  File name:   ViewportTitleDlg.h
//  Version:     v1.00
//  Created:     15/9/2004 by Timur.
//  Compilers:   Visual Studio.NET
//  Description: 
// -------------------------------------------------------------------------
//  History:
//
////////////////////////////////////////////////////////////////////////////

#ifndef __ViewportTitleDlg_h__
#define __ViewportTitleDlg_h__
#pragma once


#include "Controls/EditWithButton.h"
#include "Renderviewport.h"

// CViewportTitleDlg dialog
class CLayoutViewPane;

//////////////////////////////////////////////////////////////////////////
class CViewportTitleDlg : public CXTResizeDialog, public IEditorNotifyListener
{
	DECLARE_DYNAMIC(CViewportTitleDlg)

public:
	CViewportTitleDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CViewportTitleDlg();

	void SetViewPane( CLayoutViewPane *pViewPane );
	void SetTitle( const CString &title );
	void SetViewportSize( int width,int height );
	void SetActive( bool bActive );
	void SetFocusToSearchField();

// Dialog Data
	enum { IDD = IDD_VIEWPORT_TITLE };

	enum ESearchResultHandling
	{
		ESRH_HIDE_OTHERS = 0,
		ESRH_FREEZE_OTHERS,
		ESRH_JUST_SELECT,
	};

	enum ESearchMode
	{
		ESM_BY_NAME = 0,
		ESM_BY_TYPE,
		ESM_BY_ASSET,
	};

	static void AddResolutionMenus( CMenu& inMenu, 
									std::vector<CString>& inCustompreset, 
									UINT_PTR inBaseID,
									UINT_PTR inCustomPresetBaseID, 
									UINT_PTR inCustomBaseID,
									std::vector< CRenderViewport::SResolution >& outResolutions );

	static void LoadCustomResPresets( const char* keyName, std::vector<CString>& outCustompresets );
	static void SaveCustomResPresets( const char* keyName, const std::vector<CString>& custompresets );
	static void UpdateCustomResPresets( const CString& text, std::vector<CString>& custompresets );

protected:
	virtual BOOL OnInitDialog();
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	virtual void OnEditorNotifyEvent( EEditorNotifyEvent event );

	afx_msg void OnSetFocus( CWnd* );
	afx_msg void OnButtonSetFocus();
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnTitle();
	afx_msg void OnMaximize();
	afx_msg void OnHideHelpers();
	afx_msg void OnSize( UINT nType,int cx,int cy );
	afx_msg void OnCancel();
	afx_msg void OnSearchTermChange();
	afx_msg LRESULT OnViewportSearchButtonClicked(WPARAM wParam, LPARAM lParam);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);

	DECLARE_MESSAGE_MAP()

	CString m_title;
	//CCustomButton m_maxBtn;
	CColorCheckBox m_maxBtn;
	CColorCheckBox m_hideHelpersBtn;
	CStatic m_sizeTextCtrl;

	CLayoutViewPane *m_pViewPane;

	CStatic m_titleBtn;

	CStatic m_searchOptionsText;
	CEditWithButton m_viewportSearch;
	ESearchMode m_searchMode;
	ESearchResultHandling m_searchResultHandling;
	bool m_bOR;

	static const int MAX_NUM_CUSTOM_RES_PRESETS = 10;
	std::vector<CString> m_customResPreset;

	// Stuff for a consistent look regardless of the current skin
	CBrush m_brushGray;
	CBrush m_brushWhite;
	CBrush m_brushPattern;
	CXTPButtonTheme * m_buttonTheme;		

	void SetThemeToButton( CXTPButtonTheme* pTheme, CColorCheckBox& button );

	void UnhideUnfreezeAll();
	void SearchByType(const std::vector<CString>& terms);
	void SearchByName(const std::vector<CString>& terms);
	void SearchByAsset(const std::vector<CString>& terms);
	void UpdateSearchOptionsText();
	void InputNamesToSearchFromSelection();

	void PopUpResolutionMenu();	
};

#endif //__ViewportTitleDlg_h__
